<template>
  <div class="main">
    <Tinymce v-model="params.content" :height="300" id="Tinymce"></Tinymce>
    <el-button type="primary" :loading="loading"  @click="onSubmit">提交</el-button>
  </div>
</template>

<script>

import Tinymce from '@/components/Tinymce'
import {edit,search} from '@/api/news'
import { getToken } from '@/utils/auth'
export default {
 data(){
     return {
         loading:false,
         params:{
             content:'',
             managerId:this.$route.query.managerId,
             token:getToken(),
             type:'intro'
         }
     }
 },
methods:{
    onSubmit(){
             this.loading=true;
           edit(this.params).then((json) => {
            if(json.status === 200){
              console.log(json)
              }else{
                this.$message.error(json.data.message);
              }
          }).finally(()=>{
              this.loading=false
            });
    },
    found(){
         search({managerId:this.$route.query.managerId,type:'intro'}).then((json) => {
            if(json.status === 200){
              if(json.data){
                  this.params.content=json.data.content;
                  this.params.id=json.data.id;
              }
              }else{
                this.$message.error(json.data.message);
              }
          })
    }
},
 components:{
     Tinymce
 },
 created(){
     this.found()
 }
}
</script>

<style lang="scss" scoped>
    .main{
        width:70%;
        .el-button{
            margin-top: 20px;
        }
    }
</style>
